import Vue from 'vue'
import loginModal from "./loginModal";
let componentInstance = null
let ModalConstructor = Vue.extend(loginModal)

function createModal(){
  componentInstance = new ModalConstructor()
  document.body.appendChild(componentInstance.$mount().$el)
}

function caller(ctx) {
    if (!componentInstance) {
      createModal()
      return componentInstance.show(ctx, () => { componentInstance = null })
    }
}

export  default  {
  install(Vue){
    Vue.prototype.$loginModal = caller
  }
}
